package com.company.strs;

public class ParenthesesDepth {
    public int maxDepth(String s) {
        int depthOfParentheses = 0;
        int maxDepth = 0;
        for (int i = 0; i < s.length(); i++) {
            char cha = s.charAt(i);
            if (cha == '(') {
                depthOfParentheses++;
            }else if (cha == ')'){
                depthOfParentheses--;
            }
            if(maxDepth< depthOfParentheses){
                maxDepth = depthOfParentheses;
            }
        }
        return maxDepth;
    }
}
